package com.example.assetmanagement.mapper;

import com.example.assetmanagement.domain.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface UserMapper {

    List<User> selectPage(@Param("offset") int offset,
                          @Param("limit") int limit,
                          @Param("username") String username,
                          @Param("fullName") String fullName,
                          @Param("status") Integer status);

    long count(@Param("username") String username,
               @Param("fullName") String fullName,
               @Param("status") Integer status);

    /**
     * 根据用户名查询单个用户
     */
    User selectByUsername(@Param("username") String username);

    User selectById(@Param("id") Long id);

    int insert(User user);

    int update(User user);

    int deleteById(@Param("id") Long id);

    int deleteBatch(@Param("ids") List<Long> ids);

    int updateStatus(@Param("id") Long id, @Param("status") Integer status);

    int resetPassword(@Param("id") Long id, @Param("password") String password);

    List<User> selectAll();

    int deleteUserRoles(@Param("userId") Long userId);

    int insertUserRoles(@Param("userId") Long userId, @Param("roleIds") List<Long> roleIds);
} 